#pragma once

#include "IResultSet.h"
#include "IDatabase.h"

LIBDBC_BEGIN_NAMESPACE

class SqlResult;

class ResultSet : public IResultSet
{
public:
	ResultSet(IDatabase* pCon , SqlResult * pRes );
	virtual ~ResultSet();

	bool next();
	unsigned int getColumnCount();
	IResultSetMetaData* getResultSetMetaData();

	int getInt(int field);
	long getLong(int field);
	double getDouble(int field);
	char* getString(int field, char* buffer, int len);

	bool getInt(int field, int* pValue);
	bool getLong(int field, long* pValue);
	bool getDouble(int field, double* pValue);
	bool getStringExt(int field, char* buffer, int len);
	bool getBinaryLength(int field, unsigned long* len);
	bool getBinary(int field, unsigned char* pBuffer, int buflen);
	
	inline int getLastErrorCode() { return _errorcode; }

protected:
	IDatabase *_connection;
	SqlResult* _result;
	int _errorcode;
};

LIBDBC_END_NAMESPACE